package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class zbgq {
   private int c;
   private int d;
   private double e;
   private double f;
   private double g;
   private double h;
   private int i;
   private CellArea j;
   private int k;
   private Shape l;
   private int m;
   ArrayList a;
   boolean b = false;
   private String n;

   zbgq(Shape var1, int var2, String var3) {
      this.l = var1;
      this.m = var2;
      this.n = var3;
      int var4 = var1.getPlacement();
      if (this.l.getMsoDrawingType() == 0) {
         this.a = new ArrayList();
      }

      if (!this.l.S()) {
         double[] var5 = var1.H();
         this.c = (int)var5[2];
         this.d = (int)var5[0];
         this.e = var5[3];
         this.f = var5[1];
         this.i = (int)var5[6];
         this.k = (int)var5[4];
         this.g = var5[8];
         this.h = var5[9];
         this.l();
      }

   }

   public double a() {
      return this.e;
   }

   public void a(double var1) {
      this.e = var1;
   }

   public double b() {
      return this.f;
   }

   public void b(double var1) {
      this.f = var1;
   }

   public int c() {
      return this.c;
   }

   public int d() {
      return this.i;
   }

   public int e() {
      return this.d;
   }

   public int f() {
      return this.k;
   }

   public double g() {
      return this.g;
   }

   public void c(double var1) {
      this.g = var1;
   }

   public double h() {
      return this.h;
   }

   public void d(double var1) {
      this.h = var1;
   }

   int i() {
      return this.l.getMsoDrawingType();
   }

   Shape j() {
      return this.l;
   }

   CellArea k() {
      return this.j;
   }

   private void l() {
      this.j = new CellArea();
      this.j.StartColumn = this.e();
      this.j.EndColumn = this.f();
      this.j.StartRow = this.c();
      this.j.EndRow = this.d();
      if (this.j() instanceof CommentShape) {
         CommentShape var1 = (CommentShape)this.j();
         this.a(var1.getComment().getColumn(), var1.getComment().getRow());
      }

      if (this.j().getAutoShapeType() == 62 || this.j().getAutoShapeType() == 61 || this.j().getAutoShapeType() == 63) {
         this.m();
      }

   }

   private void m() {
      float var1 = 0.0F;
      float var2 = 0.0F;
      if (this.j().L().n().k()) {
         Geometry var3 = this.l.ag();
         ShapeGuideCollection var4 = null;
         if (var3 != null) {
            var4 = var3.f();
         }

         if (var3 != null && var4 != null && var4.getCount() >= 2) {
            ArrayList var5 = new ArrayList();
            Iterator var6 = var4.iterator();

            while(var6.hasNext()) {
               ShapeGuide var7 = (ShapeGuide)var6.next();
               String var8 = var7.b().toLowerCase();
               if (var8.startsWith("val")) {
                  String var9 = var8.substring(4).trim();
                  if (zapb.b(var9)) {
                     com.aspose.cells.b.a.a.ze.a(var5, (Object)com.aspose.cells.b.a.zo.a(var9));
                  }
               }
            }

            var1 = (float)(this.l.getWidth() / 2) + (float)this.l.getWidth() * (com.aspose.cells.b.a.ze.a(var5.get(0)) / 100000.0F);
            var2 = (float)(this.l.getHeight() / 2) + (float)this.l.getHeight() * (com.aspose.cells.b.a.ze.a(var5.get(1)) / 100000.0F);
         } else {
            var1 = (float)(this.l.getWidth() / 2) + (float)this.l.getWidth() * -0.20473F;
            var2 = (float)(this.l.getHeight() / 2) + (float)this.l.getHeight() * 0.61957F;
         }
      } else {
         zacg var10 = this.j().ai();
         if (var10.c(327) && var10.c(328)) {
            float var12 = (float)var10.b(327);
            float var13 = (float)var10.b(328);
            var1 = (float)this.l.getWidth() * (var12 / 21600.0F);
            var2 = (float)this.l.getHeight() * (var13 / 21600.0F);
         } else {
            var1 = (float)this.l.getWidth() * 0.051435184F;
            var2 = (float)this.l.getHeight() * 1.2056018F;
         }
      }

      Cells var11 = this.j().M().getCells();
      int var14 = this.j.StartColumn;
      int var15;
      if (var1 > 0.0F) {
         for(var15 = var11.getColumnWidthPixel(var14) - this.j().getLeft(); (float)var15 < var1; ++var14) {
            var15 += var11.getColumnWidthPixel(var14);
         }
      } else if (var1 < 0.0F) {
         for(var15 = -this.j().getLeft(); (float)var15 > var1; var15 -= var11.getColumnWidthPixel(var14)) {
            --var14;
         }
      }

      var15 = this.j.StartRow;
      int var16;
      if (var2 > 0.0F) {
         for(var16 = var11.getRowHeightPixel(var15) - this.j().getTop(); (float)var16 < var2; ++var15) {
            var16 += var11.getRowHeightPixel(var15);
         }
      } else if (var2 < 0.0F) {
         for(var16 = -this.j().getTop(); (float)var16 > var2; var16 -= var11.getRowHeightPixel(var15)) {
            --var15;
         }
      }

      this.a(var14, var15);
   }

   private void a(int var1, int var2) {
      if (var1 < this.j.StartColumn) {
         this.j.StartColumn = var1;
      }

      if (var1 > this.j.EndColumn) {
         this.j.EndColumn = var1;
      }

      if (var2 < this.j.StartRow) {
         this.j.StartRow = var2;
      }

      if (var2 > this.j.EndRow) {
         this.j.EndRow = var2;
      }

   }
}
